#ifndef H264_CTX_H
#define H264_CTX_H
#include "io_mng.h"
#include "slice.h"
#include "bitstream.h"
#include "h264_frame.h"
#include "nal.h"
#include "macroblock.h"
#include "quant.h"
#include "dct.h"
#include "common.h"
#include "cabac.h"

#define H264_MB_SIZE 16

typedef struct h264_ctx {
    input_img_ctx_t *input_ctx;

    // luma and chroma plane data目前只支持YUV420格式,uv分量都在H264_CHROMA_PLANE
    h264_frame_t encode_frame;
    struct sps_param_t sps;
    struct pps_param_t pps;
    bs_t bs;
    h264_slice_header_t slice_head;

    nal_t slice_nal;
    macro_block_t cur_mb;
    dct_t dct;
    quant_t quant;
    h264_cabac_t cabac;
}h264_ctx_t;

int init_h264_ctx(input_img_ctx_t *input_ctx, h264_ctx_t *ctx);

void macroblock_cache_load(h264_ctx_t *ctx, int mb_x, int mb_y);
#endif